
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{$title}|登录后台</title>
    <meta name="keywords" content="{$keywords}"/>
    <meta name="description" content="{$description}"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{__LIBS__}layui/css/layui.css"/>
    <link rel="stylesheet" href="{__MODULE__}admin.css?v=318"/>
    .

</head>

<style>
    .login-wrapper {
        max-width: 420px;
        padding: 20px;
        margin: 0 auto;
        position: relative;
        box-sizing: border-box;
        z-index: 2;
    }

    .login-wrapper > .layui-form {
        padding: 25px 30px;
        background-color: #fff;
        box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.19);
        box-sizing: border-box;
        border-radius: 4px;
    }

    .login-wrapper > .layui-form > h2 {
        color: #333;
        font-size: 18px;
        text-align: center;
        margin-bottom: 25px;
    }

    .login-wrapper > .layui-form > .layui-form-item {
        margin-bottom: 25px;
        position: relative;
    }

    .login-wrapper > .layui-form > .layui-form-item:last-child {
        margin-bottom: 0;
    }

    .login-wrapper > .layui-form > .layui-form-item > .layui-input {
        height: 40px;
        line-height: 1.5;
        border-radius: 4px !important;
    }

    .login-wrapper .layui-input-icon-group > .layui-input {
        padding-left: 40px;
    }

    .login-wrapper .layui-input-icon-group > .layui-icon {
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 18px;
        color: #909399;
        position: absolute;
        left: 0;
        top: 0;
        text-align: center;
    }

    .login-wrapper > .layui-form > .layui-form-item.login-captcha-group {
        padding-right: 135px;
    }

    .login-wrapper > .layui-form > .layui-form-item.login-captcha-group > .login-captcha {
        height: 46px;
        width: 120px;
        cursor: pointer;
        box-sizing: border-box;
        border: 1px solid #e6e6e6;
        border-radius: 4px !important;
        position: absolute;
        right: 0;
        top: 0;
    }

    .login-wrapper > .layui-form > .layui-form-item > .layui-form-checkbox {
        margin: 0 !important;
        padding-left: 25px;
    }

    .login-wrapper > .layui-form > .layui-form-item > .layui-form-checkbox > .layui-icon {
        width: 15px !important;
        height: 15px !important;
    }

    .login-wrapper > .layui-form .sf {
        display: inline-block;
        margin-bottom: 0;
        font-weight: 400;
        text-align: center;
        vertical-align: middle;
        touch-action: manipulation;
        cursor: pointer;
        background-image: none;
        border: 1px solid transparent;
        white-space: nowrap;
        user-select: none;
        height: 40px;
        padding: 0 15px;
        font-size: 16px;
        border-radius: 4px;
        transition: color .2s linear,background-color .2s linear,border .2s linear,box-shadow .2s linear;
        color: #fff;
        background-color: #fff;
        border-color: #dcdee2;
        line-height: 1.5;
        border-radius: 4px !important;
        background-color: #2d8cf0;
        border-color: #2d8cf0;
    }
    .login-wrapper > .layui-form .sf2 {
        display: inline-block;
        margin-bottom: 0;
        font-weight: 400;
        text-align: center;
        vertical-align: middle;
        touch-action: manipulation;
        cursor: pointer;
        background-image: none;
        border: 1px solid transparent;
        white-space: nowrap;
        user-select: none;
        height: 40px;
        padding: 0 15px;
        font-size: 16px;
        border-radius: 4px;
        transition: color .2s linear,background-color .2s linear,border .2s linear,box-shadow .2s linear;
        color: #000000;
        background-color: #fff;
        border-color: #dcdee2;
        line-height: 1.5;
        border-radius: 4px !important;
    }

    .login-wrapper > .layui-form > .layui-form-item.login-oauth-group > a > .layui-icon {
        font-size: 26px;
    }

    .login-copyright {
        color: #eee;
        padding-bottom: 20px;
        text-align: center;
        position: relative;
        z-index: 1;
    }

    @media screen and (min-height: 550px) {
        .login-wrapper {
            margin: -250px auto 0;
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            width: 100%;
        }

        .login-copyright {
            position: absolute;
            bottom: 0;
            right: 0;
            left: 0;
        }
    }

    .layui-btn {
        background-color: #5FB878;
        border-color: #5FB878;
    }

    .layui-link {
        color: #5FB878 !important;
    }

    .login-captcha-btn {
        line-height: 44px;
        text-align: center;
        background-color: transparent;
        outline: none;
        color: #666;
        padding: 0 !important;
    }

    /** 获取图形验证码弹窗 */
    .layer-get-code {
        padding: 25px 25px;
    }

    .layer-get-code > p {
        color: #666;
        font-size: 16px;
    }

    .layer-get-code > .lay-code-group {
        position: relative;
        padding-right: 135px;
        margin: 15px 0;
    }

    .layer-get-code > .lay-code-group > .layui-input {
        border-radius: 0;
        height: 46px;
        line-height: 46px;
        background-color: transparent;
        border-color: rgba(111, 121, 122, 0.3);
    }

    .layer-get-code > .lay-code-group > img {
        position: absolute;
        right: 0;
        top: 0;
        height: 46px;
        width: 120px;
        box-sizing: border-box;
        cursor: pointer;
    }

    .layer-get-code .layui-btn-fluid {
        line-height: 50px;
        height: 50px;
    }

    .logo {
        width: 60px !important;
        margin-top: 10px !important;
        margin-bottom: 10px !important;
        margin-left: 20px !important;
    }
    .title {
        font-size: 30px !important;
        font-weight: 550 !important;
        margin-left: 20px !important;
        color: #3492ed !important;
        display: inline-block !important;
        height: 60px !important;
        line-height: 60px !important;
        margin-top: 10px !important;
        position: absolute !important;
    }

    .desc {
        width: 100% !important;
        text-align: center !important;
        color: gray !important;
        height: 60px !important;
        line-height: 60px !important;
    }
    .page-account-other {
        margin: 24px 0;
        text-align: left;
    }
    .page-account-other img {
        width: 24px;
        margin-left: 16px;
        cursor: pointer;
        vertical-align: middle;
        opacity: .7;
        transition: all .2s ease-in-out;
    }
</style>
<body style="background-image: url('{__IMG__}background.svg');background-size: cover;">
<div class="login-wrapper layui-anim layui-anim-scale layui-hide">
    <form class="layui-form layui-card-body" id="divLoading"
    style="padding: 28px 15px;box-sizing: border-box;min-height: 126px;opacity: 0.95">
        <div class="layui-form-item">
            <img class="logo" src="{__IMG__}logo.png" />
            <div class="title">Admin Login</div>
            <div class="desc">
               SF 授 权 系 统 后 台 管 理 中 心
            </div>
        </div>
        <div class="layui-form-item layui-input-icon-group">
            <i class="layui-icon layui-icon-username"></i>
            <input class="layui-input" name="user" placeholder="请输入登录账号" autocomplete="off"
                   lay-verType="tips" lay-verify="required" >
        </div>
        <div class="layui-form-item layui-input-icon-group">
            <i class="layui-icon layui-icon-password"></i>
            <input class="layui-input" name="pass" placeholder="请输入登录密码" type="password"
                   lay-verType="tips" lay-verify="required" >
        </div>
        <div class="layui-form-item">
            <input type="checkbox" name="remember" title="记住密码" lay-skin="primary" checked>
            <a href="reg.html" class="layui-link pull-right">注册用户</a>
        </div>
        <div class="layui-form-item">
            <button type="button" class="layui-btn layui-btn-fluid sf" id="login">登录</button>
        </div>
        <div class="layui-form-item page-account-other" style="font-size: 14px;">
            <span>其他登录方式</span>
            <a id="wechat_login"><img src="{__IMG__}wechat.svg" alt="微信"></a><a id="qq_login"><img src="{__IMG__}qq.svg" alt="qq"></a><a id="code"><img src="{__IMG__}code.svg" alt="扫码"></a>&emsp;
        </div>
    </form>
</div>

<script src="//lib.baomitu.com/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="{__LIBS__}layui/layui.js"></script>
<script type="text/javascript" src="{__JS__}common.js?v=318"></script>
<script src="{__JS__}gt.js"></script>
<script>
    layui.use(['layer', 'form', 'admin', 'notice'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var notice = layui.notice;
        $('.login-wrapper').removeClass('layui-hide');

        $("#wechat_login").click(function(){
            notice.error({
                title: 'SF提示您',
                message: '暂不支持',
                animateInside:true,
                position:'topCenter',
                transitionOut:'flipOutX',
                transitionOutMobile: 'flipOutX',
                displayMode:'2',
                audio:'1'
            });
        });
        $("#code").click(function(){
            admin.open({
                type: 1,
                area:['300px',''],
                title:'SF-扫码登录',
                content: '<div class="form-group" style="text-align: center;"><div style="margin-top:1rem;margin-bottom:1rem;color:#666" id="login"><span id="loginmsg">请使用QQ手机版扫描二维码</span><span id="loginload" style="color: #790909;">.</span></div><div id="qrimg"></div><button type="button" id="mlogin" onclick="mloginurl()" class="layui-btn layui-btn-fluid layui-btn-normal">跳转QQ快捷登录</button></div>'
            });
        });
        {if $code != ''}
        admin.btnLoading('#login');
        admin.showLoading('#divLoading', 2, '.8');
        $.ajax({
            type: "post",
            url: "/api.php/Social/login",
            data: {
                "code": "{$code}",
                "state": "{$state}",
                "userType": "admin",
            },
            dataType: "json",
            success: function(data) {
                if (data.code == 0) {
                    notice.msg('正在为您跳转QQ登录页面...', {icon: 4, close: true, audio:'1'});
                    setTimeout(function (){
                        notice.destroy();
                        location.href=data.data.url;
                    },1000)
                } else {
                    notice.error({
                        title: 'SF提示您',
                        message: data.msg,
                        animateInside:true,
                        position:'topCenter',
                        transitionOut:'flipOutX',
                        transitionOutMobile: 'flipOutX',
                        displayMode:'2',
                        audio:'1'
                    });
                }
                admin.removeLoading('#divLoading', true, true);
                admin.btnLoading('#login', false);
            }, error: function () {
                notice.error({
                    title: 'SF提示您',
                    message: '服务器错误，请稍后重试~',
                    animateInside:true,
                    position:'topCenter',
                    transitionOut:'flipOutX',
                    transitionOutMobile: 'flipOutX',
                    timeout:false,
                    displayMode:'2',
                    audio:'1'
                });
                admin.removeLoading('#divLoading', true, true);
                admin.btnLoading('#login', false);
                return false;
            }
        });
        {/if}
        $("#qq_login").click(function(){
            admin.btnLoading('#login');
            admin.showLoading('#divLoading', 2, '.8');
            $.ajax({
                type: "post",
                url: "/api.php/Social/login",
                data: {
                    "userType": "admin",
                },
                dataType: "json",
                success: function(data) {
                    if (data.code == 0) {
                        notice.msg('正在为您跳转QQ登录页面...', {icon: 4, close: true, audio:'1'});
                        setTimeout(function (){
                            notice.destroy();
                            location.href=data.data.url;
                        },1000)
                    } else {
                        notice.error({
                            title: 'SF提示您',
                            message: data.msg,
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                    }
                    admin.removeLoading('#divLoading', true, true);
                    admin.btnLoading('#login', false);
                }, error: function () {
                    notice.error({
                        title: 'SF提示您',
                        message: '服务器错误，请稍后重试~',
                        animateInside:true,
                        position:'topCenter',
                        transitionOut:'flipOutX',
                        transitionOutMobile: 'flipOutX',
                        timeout:false,
                        displayMode:'2',
                        audio:'1'
                    });
                    admin.removeLoading('#divLoading', true, true);
                    admin.btnLoading('#login', false);
                    return false;
                }
            });
        });

        {if $captcha_open == '1'}
            var handlerEmbed = function(captchaObj) {
                var target;
                captchaObj.onReady(function() {
                    $("#wait").hide();
                }).onSuccess(function() {
                    var result = captchaObj.getValidate();
                    var user = $("input[name='user']").val();
                    var pass = $("input[name='pass']").val();
                    if (!result) {
                        notice.warning({
                            title: 'SF提示您',
                            message: '请完成验证！',
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                        return false;
                    }
                    admin.btnLoading('#login');
                    admin.showLoading('#divLoading', 2, '.8');
                    $.ajax({
                        type: "post",
                        url: "{:url('/Login/login')}",
                        data: {
                            "username": user,
                            "password": pass,
                            "geetest_challenge": result.geetest_challenge,
                            "geetest_validate": result.geetest_validate,
                            "geetest_seccode": result.geetest_seccode
                        },
                        dataType: "json",
                        success: function(data) {
                            if (data.code == 0) {
                                notice.success({
                                    title: 'SF提示您',
                                    message: data.msg,
                                    animateInside:true,
                                    position:'topCenter',
                                    transitionOut:'flipOutX',
                                    transitionOutMobile: 'flipOutX',
                                    displayMode:'2',
                                    audio:'1'
                                });
                                setTimeout(function (){
                                    location.href="{:url('/Index/index')}";
                                },2000)
                            } else {
                                notice.error({
                                    title: 'SF提示您',
                                    message: data.msg,
                                    animateInside:true,
                                    position:'topCenter',
                                    transitionOut:'flipOutX',
                                    transitionOutMobile: 'flipOutX',
                                    displayMode:'2',
                                    audio:'1'
                                });
                            }
                            admin.removeLoading('#divLoading', true, true);
                            admin.btnLoading('#login', false);
                        }, error: function () {
                            notice.error({
                                title: 'SF提示您',
                                message: '服务器错误，请稍后重试~',
                                animateInside:true,
                                position:'topCenter',
                                transitionOut:'flipOutX',
                                transitionOutMobile: 'flipOutX',
                                timeout:false,
                                displayMode:'2',
                                audio:'1'
                            });
                            admin.removeLoading('#divLoading', true, true);
                            admin.btnLoading('#login', false);
                            return false;
                        }
                    });
                });
                $('#login').click(function() {
                    if ($(this).attr("data-lock") === "true") return;
                    var user = $("input[name='user']").val();
                    var pass = $("input[name='pass']").val();
                    if(!user){
                        notice.warning({
                            title: 'SF提示您',
                            message: '请填写用户名！',
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                        return false;
                    }
                    if(!pass){
                        notice.warning({
                            title: 'SF提示您',
                            message: '请填写密码！',
                            animateInside:true,
                            position:'topCenter',
                            transitionOut:'flipOutX',
                            transitionOutMobile: 'flipOutX',
                            displayMode:'2',
                            audio:'1'
                        });
                        return false;
                    }
                    captchaObj.verify();
                });
                // 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
            };
            $.ajax({
                // 获取id，challenge，success（是否启用failback）
                url: "/api.php/Captcha/?t=" + (new Date()).getTime(),
                // 加随机数防止缓存
                type: "get",
                asysn: true,
                dataType: "json",
                success: function(data) {
                    console.log(data);
                    // 使用initGeetest接口
                    // 参数1：配置参数
                    // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
                    initGeetest({
                            width: '100%',
                            gt: data.gt,
                            challenge: data.challenge,
                            new_captcha: data.new_captcha,
                            product: "bind",
                            // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                            offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
                            // 更多配置参数请参见：http://www.geetest.com/install/sections/idx-client-sdk.html#config
                        },
                        handlerEmbed);
                }
            });
        {else/}
            $('#login').click(function() {
                var user = $("input[name='user']").val();
                var pass = $("input[name='pass']").val();
                if(!user || !pass){
                    layer.msg('账号或密码不能为空！');
                    return false;
                }
                load=layer.load(0);
                $.ajax({
                    type: "post",
                    url: "{:url('/login')}",
                    data: {
                        "username": user,
                        "password": pass,
                    },
                    dataType: "json",
                    success: function(data) {
                        layer.close(load);
                        if (data.code == 0) {
                            layer.msg(data.msg);
                            window.location.href="./index.php";
                        } else {
                            layer.msg(data.msg);
                        }
                    }
                });
            });
        {/if}
    });
</script>